package problem;

public class S_125 {
    //验证回文串,只考虑字母和数字字符
    //1.双指针法
    class Solution {
        public boolean isPalindrome(String s) {
            int i=0,j=s.length()-1;
            while(i<j){
                while(i<j&&!Character.isLetterOrDigit(s.charAt(i))) i++;
                while(i<j&&!Character.isLetterOrDigit(s.charAt(j))) j--;
                if(Character.toLowerCase(s.charAt(i))!=Character.toLowerCase(s.charAt(j))) return false;
                i++;j--;
            }
            return true;
        }
    }
}
